//
//  GuideViewController.m
//  dangdang
//
//  Created by air on 16/3/18.
//  Copyright © 2016年 luweijie. All rights reserved.
//

#import "GuideViewController.h"
#import "HomepageViewController.h"

@interface GuideViewController ()

@property (nonatomic, strong) UIScrollView * myScrollView;
@property (nonatomic) NSInteger count;

@end

@implementation GuideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _count = 0;
    
    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(homePush)];
    tap.numberOfTapsRequired = 1;
    [self.view addGestureRecognizer:tap];
    
    UIImageView * imageV = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    imageV.image = [UIImage imageNamed:@"01.png"];
    [self.view addSubview:imageV];
}

- (void)homePush{
    if (_count > 1) {
        //判断 我是否创建了文件，如果没创建 就创建这个文件（这种情况就运行一次，也就是第一次启动程序的时候）
        NSString * guidePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0]stringByAppendingPathComponent:@"prologue.plist"];
        if ([[NSFileManager defaultManager] fileExistsAtPath:guidePath] == NO){
            NSMutableArray * cityDataArray = [[NSMutableArray alloc]init];
            NSString * string = @"1";
            [cityDataArray addObject:string];
            [cityDataArray writeToFile:guidePath atomically:YES];
        }
        
        HomepageViewController * homeboardVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"HomepageViewController"];
        UINavigationController * navi = [[UINavigationController alloc] initWithRootViewController:homeboardVC];
        [self presentViewController:navi animated:YES completion:nil];
        return;
    }
    NSArray *arr=[NSArray arrayWithObjects:@"02.png", @"03.png", nil];
    UIImageView * imageV = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    imageV.image = [UIImage imageNamed:arr[_count]];
    [self.view addSubview:imageV];
    _count ++;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
